package com.bw.kotlindemo.kotlin.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.get
import com.bw.kotlindemo.kotlin.kvm.KLiveVM
import java.lang.reflect.ParameterizedType

/**
 * desc:基类
 * create by xushaodong on 2023/4/5
 */
abstract class KBaseActivity<VM : KBaseViewModel,DBD : ViewDataBinding> : AppCompatActivity() {
    lateinit var vm:VM
    lateinit var mDataBinding:DBD

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mDataBinding = DataBindingUtil.setContentView<DBD>(this,initLayout())
        vm = initViewModel();
        initData();
    }

    abstract fun initLayout(): Int

    abstract fun initData()

    abstract fun initViewModel():VM
}